package com.turing.post.organization.util;

import java.math.BigInteger;
import java.util.Date;
import java.util.List;

import javax.ejb.Local;
import javax.ejb.Remote;

import com.turing.post.util.PCPSApplicationException;
import com.turing.post.util.PCPSWebInput;

/**
 * 商户手续费收入结算策略数据访问接口
 * 
 * @author zxp
 * @Jan 3, 2013
 */
@Remote
@Local
public interface MerchantFeeSettlementPolicyDao {

	/**
	 * 根据主键查询商户手续费收入结算策略
	 * 
	 * @param feePolicyId
	 *            费率id
	 * @return MerchantFeeSettlementPolicy 商户手续费收入结算策略
	 */
	public MerchantFeeSettlementPolicy getMerchantFeeSettlementPolicyByFeePolicyId(
			BigInteger feePolicyId);

	/**
	 * 查询所属发卡商下拉框
	 * 
	 * @param webInput
	 *            日志记录对象
	 * @return List 商户手续费收入结算策略列表
	 */
	public List<MerchantFeeSettlementPolicy> getMerchantFeeSettlementPolicyDropdownList(
			PCPSWebInput webInput);

	/**
	 * 记录商户手续费收入结算策略列表
	 * 
	 * @param webInput
	 * @param merchantNo
	 * @param status
	 * @param policy
	 * @param page
	 * @return
	 */
	public List<MerchantFeeSettlementPolicy> getMerchantFeeSettlementPolicyList(
			PCPSWebInput webInput, String merchantNo, String status,
			String policy, Integer page);

	/**
	 * 记录商户手续费收入结算策略总数
	 * 
	 * @param webInput
	 * @param merchantNo
	 * @param status
	 * @param policy
	 * @return
	 */
	public BigInteger getMerchantFeeSettlementPolicyTotal(
			PCPSWebInput webInput, String merchantNo, String status,
			String policy);

	/**
	 * 新增商户手续费收入结算策略
	 * 
	 * @param merchantFeeSettlementPolicy
	 *            商户手续费收入结算策略
	 * @throws PCPSApplicationException
	 */
	public void insertMerchantFeeSettlementPolicy(
			MerchantFeeSettlementPolicy merchantFeeSettlementPolicy)
			throws PCPSApplicationException;

	/**
	 * 修改商户手续费收入结算策略
	 * 
	 * @param merchantFeeSettlementPolicy
	 *            商户手续费收入结算策略
	 * @throws PCPSApplicationException
	 */
	public void updateMerchantFeeSettlementPolicy(
			MerchantFeeSettlementPolicy merchantFeeSettlementPolicy)
			throws PCPSApplicationException;

	/**
	 * 删除商户手续费收入结算策略
	 * 
	 * @param feePolicyId
	 *            费率id
	 * @throws PCPSApplicationException
	 */
	public void deleteMerchantFeeSettlementPolicyByFeePolicyId(
			BigInteger feePolicyId) throws PCPSApplicationException;

	/**
	 * 根据商户号，起止时间段取得结算策略的集合
	 * 
	 * @param merchantNo
	 * @param trandate
	 * @return MerchantFeeSettlementPolicy集合
	 */
	public List<MerchantFeeSettlementPolicy> getMerchantFeeSettlementPolicyListByMerchantnoAndTimeQuantum(
			String merchantNo, Date startdate, Date enddate);

	/**
	 * 根据商户号，trandate取得结算策略的集合
	 * 
	 * @param merchantNo
	 * @param trandate
	 * @return MerchantFeeSettlementPolicy集合
	 */
	public List<MerchantFeeSettlementPolicy> getMerchantFeeSettlementPolicyListByMerchantnoAndTrandate(
			String merchantNo, Date trandate);

	/**
	 * 根据商户号，trandate取得所有达到阀值的结算策略的集合
	 * 
	 * @param merchantNo
	 * @param trandate
	 * @return MerchantFeeSettlementPolicy集合
	 */
	public List<MerchantFeeSettlementPolicy> getEffectMerchantFeeSettlementPolicyList(
			String merchantNo, Date trandate);

	/**
	 * 判断是否存在指定商户指定日期且已批准的结算策略
	 * 
	 * @param merchantNo
	 * @param tranDate
	 * @return int ( = 0 - 无策略 0x01 - 有非业务类型策略 0x80 - 有按业务类型结算策略 )
	 */
	public int getSettlementPolicyCategory(String merchantNo, Date tranDate);

	/**
	 * 根据商户号,起始日期 获取商户手续费收入结算策略(日期包含或者交叉)的集合
	 * 
	 * @param merchantNo
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public List<MerchantFeeSettlementPolicy> getMFSPByMrchNoAndDateInclude(
			String merchantNo, Date startDate, Date endDate, String policy,
			String businessType, BigInteger limitAmount);

	/**
	 * 根据商户号,起始日期 获取商户手续费收入结算策略(日期重叠)的集合
	 * 
	 * @param merchantNo
	 * @param startDate
	 * @param endDate
	 * @return
	 */
	public List<MerchantFeeSettlementPolicy> getMFSPByMrchNoAndDateOverlapping(
			String merchantNo, Date startDate, Date endDate, String policy,
			String businessType, BigInteger limitAmount);

	/**
	 * 根据商户号和合同号,获取对应策略列表
	 * 
	 * @param webInput
	 * @param merchantNo
	 * @param contractId
	 * @return
	 */
	public List<MerchantFeeSettlementPolicy> getMFSPListForContract(
			PCPSWebInput webInput, String merchantNo, String contractId,
			Integer page);

	/**
	 * 根据商户号和合同号,获取对应策略数目
	 * 
	 * @param webInput
	 * @param merchantNo
	 * @param contractId
	 * @return
	 */
	public BigInteger getMFSPTotalForContract(PCPSWebInput webInput,
			String merchantNo, String contractId);

	/**
	 * 更新合同关联的结算策略
	 * 
	 * @param contractId
	 * @param status
	 */
	public void updateMFSPByContractId(BigInteger contractId,
			MerchantFeeSettlementPolicy mfsp) throws PCPSApplicationException;

	/**
	 * 根据商户号和合同号,删除对应的结算策略
	 * 
	 * @param webInput
	 * @param merchantNo
	 * @param contractId
	 */
	public void removeMFSPTotalForContract(PCPSWebInput webInput,
			String merchantNo, String contractId)
			throws PCPSApplicationException;

	/**
	 * 合同延期时资费策略同时延期
	 * 
	 * @param contractId
	 * @throws PCPSApplicationException
	 */
	public void modifyMFSPEndDateByContractId(BigInteger contractId,
			BigInteger extensionMonth) throws PCPSApplicationException;

	/**
	 * 根据商户号和合同号,获取对应策略数目
	 * 
	 * @param merchantNo
	 * @param contractId
	 * @param policy
	 * @return
	 */
	public Integer checkMFSPTotalForContract(String merchantNo,
			String contractId, String policy);

}